/*
============================================================================
 Name        : nmsJpeg.h
 Author      : Jian
 Version     :
 Copyright   : base on http://ce.sharif.edu/~ahmadinejad/jpeg/
 Description : nmsJpeg.h - header file
============================================================================
*/

#ifndef NMSJPEG_H
#define NMSJPEG_H

#ifdef __cplusplus
extern "C" {
#endif

#include "nmsJpegDefine.h"

/* Forward declaration */
struct __nms_jpeg_frame ;
struct __nms_huffman ;


typedef struct __nms_sos_comp {
    UINT8 id ;
    UINT8 acHTIndex ;
    UINT8 dcHTIndex ;
    UINT8 dummy ;
} nmsSosComp ;

typedef struct __nms_jpeg {
    HFILE    fileHandle ;
    
    WCHAR*   fileName ;
    int      fileSize ;
    int      imgDataPos ;

    int      mcuWidth ;
    int      mcuHeight ;

    int      mcuPerLine ;
    int      mcuLine ;

    struct __nms_jpeg_frame* frame ;
    nmsJpegDqt*              qt[__NMS_MAX_DQT_INDEX + 1] ;
    struct __nms_huffman*    acTable[__NMS_MAX_DHT_INDEX + 1] ;
    struct __nms_huffman*    dcTable[__NMS_MAX_DHT_INDEX + 1] ;
    struct __nms_sos_comp    sosComp[__NMC_JPEG_COMP_ID_CR + 1] ;

} nmsJpeg;


nmsJpeg* nmsJpegOpen(const WCHAR* aFilename) ;

void nmsJpegClose(nmsJpeg* jpg) ;

int nmsJpegGetSize(const nmsJpeg* jpg, int* width, int* height) ;

/*
 * aFilename: new file name to save
 * scale:     scale of jpeg to saved: must > 0 && <= 100)
*/
int nmsJpegSave(nmsJpeg* jpg, const WCHAR* aFilename, UINT32 scale) ;


#ifdef __cplusplus
}
#endif

#endif /* NMSJPEG_H*/

/* End of File */
